
import javax.swing.*;

import java.awt.color.*;
import java.awt.*;
import java.awt.event.*;
public class CommFrame extends JFrame implements ActionListener{
    JMenuBar bar;
    JMenu menu;
    JMenuItem scanItem,deleteItem,updateItem,insertItem,searchItem;
    Scan_stu scan;//查看所有学生信息
    Delete_stu delete;//删除学生信息
    Update_stu update;//更新学生信息
    Insert_stu insert;//插入学生信息
    Search_stu search;//查找学生信息
    CardLayout card=null;
    JPanel pCenter;
    CommFrame(){
        setLayout(new FlowLayout());
        scanItem=new JMenuItem("用户管理");
        deleteItem=new JMenuItem("博客管理");
        updateItem=new JMenuItem("修改");
        insertItem =new JMenuItem("添加");
        searchItem=new JMenuItem("查找");
        bar=new JMenuBar();
        menu=new JMenu("菜单");
        menu.add(scanItem);
        menu.add(deleteItem);
        menu.add(updateItem);
        menu.add(insertItem);
        menu.add(searchItem);
        bar.add(menu);
        setJMenuBar(bar);
        scanItem.addActionListener(this);
        deleteItem.addActionListener(this);
        updateItem.addActionListener(this);
        insertItem.addActionListener(this);
        searchItem.addActionListener(this);
        scan=new Scan_stu();
        update=new Update_stu();
        delete=new Delete_stu();
        insert=new Insert_stu();
        search=new Search_stu();
        card=new CardLayout();
        pCenter=new JPanel();
        pCenter.setLayout(card);
        pCenter.add("scanItem", scan);
        pCenter.add("deleteItem",delete);
        pCenter.add("updateItem",update);
        pCenter.add("insertItem",insert);
        pCenter.add("searchItem",search);
        add(pCenter,BorderLayout.SOUTH);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        setBounds(400,150,550,400);
        setTitle("学生信息管理系统");
        validate();
    }
    public void actionPerformed(ActionEvent e){
        if(e.getSource()==scanItem)
            card.show(pCenter, "scanItem");
        else if(e.getSource()==deleteItem)
            card.show(pCenter, "deleteItem");
        else if(e.getSource()==updateItem)
            card.show(pCenter, "updateItem");
        else if(e.getSource()==insertItem)
            card.show(pCenter, "insertItem");
        else if(e.getSource()==searchItem)
            card.show(pCenter, "searchItem");
    }

}
